package io.renren.service.impl;

import io.renren.entity.SysUserEntity;
import io.renren.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import io.renren.dao.EmpBlacklistDao;
import io.renren.entity.EmpBlacklistEntity;
import io.renren.service.EmpBlacklistService;



@Service("empBlacklistService")
public class EmpBlacklistServiceImpl implements EmpBlacklistService {
	@Autowired
	private EmpBlacklistDao empBlacklistDao;
	
	@Override
	public EmpBlacklistEntity queryObject(Integer id){
		return empBlacklistDao.queryObject(id);
	}
	
	@Override
	public List<EmpBlacklistEntity> queryList(Map<String, Object> map){
		return empBlacklistDao.queryList(map);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return empBlacklistDao.queryTotal(map);
	}
	
	@Override
	public void save(EmpBlacklistEntity empBlacklist){
		SysUserEntity user= (SysUserEntity) ShiroUtils.getSubject().getSession().getAttribute("user");
		empBlacklist.setLockTime(new Date());
		empBlacklist.setLockPerson(user.getUserdesc());
		empBlacklist.setIfLock("0");
		empBlacklistDao.save(empBlacklist);
	}

	@Override
	public void update(EmpBlacklistEntity empBlacklist){
		empBlacklistDao.update(empBlacklist);
	}
	
	@Override
	public void delete(Integer id){
		empBlacklistDao.delete(id);
	}
	
	@Override
	public void deleteBatch(Integer[] ids){
		empBlacklistDao.deleteBatch(ids);
	}


	@Override
	public void unlock(EmpBlacklistEntity empBlacklist){
		SysUserEntity user= (SysUserEntity) ShiroUtils.getSubject().getSession().getAttribute("user");
		empBlacklist.setUnLockTime(new Date());
		empBlacklist.setUnLockPerson(user.getUserdesc());
		empBlacklist.setIfLock("1");
		empBlacklistDao.update(empBlacklist);
	}
	
}
